<#include "../layout/layout.ftl">
<#macro overrideHead>
<title>系统备份</title>
</#macro>
<#macro overrideContainer>
<div id="page-wrapper">
    <div class="container-fluid">
        <div class="row" style="height: 100%">
            <div class="col-lg-12">
                <ol class="breadcrumb">
                    <li class="active">
                        系统备份
                    </li>
                </ol>
                <hr>
            </div>
        </div>
        <div class="row" >
            <div class="col-lg-3 col-sm-12 col-lg-offset-3" style="position: relative;">
                <div>
                    <span class="col-lg-3  col-xs-12 label label-success" style="text-align: center;height: 25px;width: 100%;padding-top: 5px;">系统每天凌晨自动备份</span>
                </div>

            </div>

        </div>
        <div class="row" style="margin-top: 20px;margin-bottom: 20px">
            <div class="col-lg-3 col-lg-offset-3">
                <button type="button" onclick="executeBackup()" class="btn btn-primary col-xs-12 col-lg-1.5" id="crawlerBtn" style="margin-bottom: 20px">备份
                </button>
                <button type="button" onclick="downloadBackup()" class="btn btn-primary col-xs-12 col-lg-1.5" id="crawlerBtn" style="float: right">下载</button>
                <form id="downloadBackup"  action="/back/admin/backup/download" style="display: none"></form>
            </div>
        </div>
    </div>
</div>
</#macro>
<#macro overrideScript>
<script>
    $(function () {

    });

    /**
     * 系统备份
     */
    function executeBackup() {
        var index= layer.load(1);
        $.ajax({
            url: "/back/admin/execute/backup",
            type: "GET",
            success: function (data) {

                if(data.success==true){
                    layer.close(index);
                    layer.msg(data.result,{icon:1})
                }
            },
            error: function(data){
                alert(data.result);
            }
        });
    }

    /**
     * 下载备份文件
     */

    function downloadBackup() {
       $("#downloadBackup").submit();
    }
</script>
</#macro>
<@layout head=overrideHead container=overrideContainer script=overrideScript>
</@layout>